package kiv.janecekz;

import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

import android.view.View;
import android.widget.NumberPicker;
import android.widget.SeekBar;

public class ObserversUpdater implements Observer {
    private ArrayList<View> views = new ArrayList<View>();

    public void addView(View v) {
        views.add(v);
    }

    public void update(Observable observable, Object data) {
        for (View view : views) {
            if (view instanceof SeekBar) {
                ((SeekBar) view).setProgress(((Tempomat) observable).getBPM()
                        - Tempomat.MIN_BPM);
            }
            if (view instanceof NumberPicker) {
                ((NumberPicker) view)
                        .setValue(((Tempomat) observable).getBPM());
            }
        }
    }

}
